<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>02.设置一个不可修改的属性 </title>
</head>

<body>
    <h1>02.设置一个不可修改的属性 </h1>
    <script>
        const user = {
            username:'laoxie',
            age: 18,
            gender:'male'
        }
        Object.defineProperty(user, 'age', {
            // configurable:true,
            writable: false,
            // enumerable:false
        })

        Object.defineProperty(user,'age',{
            enumerable:true
        })

        Object.defineProperty(user,'hobby',{
            value:'大保健'
        })

        const student = {
            username:'jingjing',
            get age(){
                return user.age
            },
            set age(newValue){
                user.age = newValue;
            }
        }
    </script>
</body>

</html>